package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws IOException {
        Scanner scan=new Scanner(System.in);
        FileOutputStream file=new FileOutputStream("pw.txt",true);
        OutputStreamWriter o=new OutputStreamWriter(file, StandardCharsets.UTF_8);
        BufferedWriter bu=new BufferedWriter(o);
        PrintWriter pw=new PrintWriter(bu,true);
        while (true){
            System.out.println("输入一串字符");
            String s=scan.nextLine();
            if ("exit".equalsIgnoreCase(s)){
                break;
            }else {
                pw.println(s);
                System.out.println("写入完成");
            }
        }
        pw.close();
    }
}
